home *** CD-ROM | disk | FTP | other *** search
- /**
- * chgpass.c
- *
- * Allow the Password in the file PASSWRD.COM to be Changed
- * This program will first read in the ENTIRE PASSWRD.COM file
- * and extract the six (6) characters of the password.
- * The Password MUST be retyped exactly to be changed.
- * The PASSWRD.COM file is then written back out to the disk.
- *
- * I appologize for this not being a good example of 'C' coding
- * but, I wrote it without a manual handy and Strings and I still
- * have a problem in 'C'.
- *
- * This program was written using Lattice 'C' Compiler ver 2.14
- *
- * Garth Kennedy 26 December 1984
- **/
- #include "_main.c"
-
- main()
- {
- static char pass[300]; /* data file for PASSWRD.COM */
- static char *passf = "PASSWRD.COM"; /* file name */
- char *p; /* pointer to first block of data */
- FILE *fp; /* file pointer */
- int nact; /* number of blocks read/written */
- int n; /* number of blocks to be read/written */
- int s; /* size of each block, in bytes */
- char *mode = "rb+"; /* read/write a file -untranslated */
- int ret; /* return code */
- static char pw1[10],pw2[10]; /* temp holding for new passwords */
- int i,j,k,l;
- char c,d;
-
- s = 0xFE; /* size of PASSWRD.COM */
- n = 1; /* one block to be read */
- p = &pass[0]; /* pointer to beginning of data file */
- fp = fopen(passf,mode); /* open the file */
- nact = fread(p,s,n,fp); /* read data block from disc */
- ret = fclose(fp); /* close the disc file */
-
- /* Print out CRT Header */
- printf(" Change the Password Program 26 Dec 1984\n\n");
- printf(" This program is in the public domain the program may\n");
- printf(" be copied and used without charge.\n");
- printf(" Copyright KJ Consulting 1984\n\n");
-
- printf("\n This program will allow the password to be changed");
- printf("\n in the password program PASSWRD.COM.\n");
- printf("\n You will be asked to 1.) Enter the current Password\n");
- printf(" 2.) Enter the New Password\n");
- printf(" 3.) Reenter the New Password\n");
- printf("\n At no time will any of the keystrokes appear on the CRT");
- printf("\n This was done to prevent problems with password 'stealing'");
- printf("\n At any point at which the Passwords dont match this program\n");
- printf(" will terminate\n\n");
-
- /* extract the Password characters from the .com file */
- pw1[0] = pass[0xAC],pw1[1]= pass[0xB1],pw1[2] = pass[0xB6];
- pw1[3] = pass[0xBB],pw1[4] = pass[0xC0],pw1[5] = pass[0xC5];
-
- i = 0,j = 0,l = 0;
- printf("Please enter the current Password (6 characters) - ");
- for (i = 0;i <= 5;i++) /* manually enter to confirm */
- {
- c = getch(); /* check char by char */
- printf("."); /* j will be non-zero if wrong */
- if (c != pw1[i])
- j++;
- }
- printf("\n");
- if (j != 0 ) /* didnt match */
- {
- printf("\n\n !!! SORRY !!! Wrong Password Entered \n\n");
- exit();
- }
- while (l == 0)
- {
- printf("\nPlease Enter the New Password. Exactly Six (6) Characters - ");
- for (i = 0;i <= 5;i++)
- {
- pw2[i] = getch();
- printf(".");
- }
- printf("\n");
-
- j = 0;
- printf("Please Reenter the New Password (6 characters) - ");
- for (i = 0;i <= 5;i++) /* manually enter to confirm */
- {
- c = getch(); /* check reentry character by char */
- if (c != pw2[i]) j++; /* j non-zero if no match */
- printf(".");
- }
- printf("\n");
- if (j == 0)
- l = 999; /* new password checks */
- } /* end of if l == 0 */
- /* if j non-zero repeat the whole new password */
- /* loop - values will be reentered */
-
- printf("Saving the new Password\n\n"); /* passwords matched */
- pass[0xAC] = pw2[0],pass[0xB1] = pw2[1],pass[0xB6] = pw2[2];
- pass[0xBB] = pw2[3],pass[0xC0] = pw2[4],pass[0xC5] = pw2[5];
-
- s = 0xFE; /* size of PASSWRD.COM */
- n = 1; /* one block to be read */
- p = &pass[0]; /* pointer to beginning of data file */
- fp = fopen(passf,mode); /* open the file */
- nact = fwrite(p,s,n,fp); /* read data block from disc */
- ret = fclose(fp); /* close the disc file */
-
- exit();
- }
-